home *** CD-ROM | disk | FTP | other *** search
/ PD ROM 1 / PD ROM Volume I - Macintosh Software from BMUG (1988).iso / Stacks / Hyper Utilities / Text Utilities / Font list 1.0 / card_3597.txt < prev    next >
Encoding:
Text File  |  1988-04-07  |  14.3 KB  |  572 lines

  1. -- card: 3597 from stack: in.0
  2. -- bmap block id: 4078
  3. -- flags: 0000
  4. -- background id: 3325
  5. -- name: Font selection simulator
  6. ----- HyperTalk script -----
  7. --**********************************************************
  8. --*            "Text Style" Simulator Script               *
  9. --*                                                        *
  10. --*                       by Dr. John A. Koch   3/30/88    *
  11. --*                          Computer Science Department   *
  12. --*                          Wilkes College                *
  13. --*                          Wilkes-Barre, PA  18766       *
  14. --*                          CompuServe: 72457,736         *
  15. --*                          AppleLink: U0192              *
  16. --*                                                        *
  17. --*    This script is messageware.  Send me a message if   *
  18. --*    you find it useful or have suggestions.             *
  19. --*                                                        *
  20. --*    This stack is ¬©1988.  May not be sold for profit.   *
  21. --*                                                        *
  22. --*    This script uses function "fontList" (in the        *
  23. --*    background script) which gets a list of system      *
  24. --*    fonts and sizes.                                    *
  25. --*                                                        *
  26. --*    Could an XFCN use the HyperCard dialog box and      *
  27. --*    return the font settings to a script?               *
  28. --*                                                        *
  29. --**********************************************************
  30.  
  31. on changecard
  32.   -- show what was set in the message box
  33.   put the textfont of card field "sample" & "," into m
  34.   put the textsize of card field "sample" & "," after m
  35.   put the textheight of card field "sample" & "," after m
  36.   put the textalign of card field "sample" & "," after m
  37.   put the textstyle of card field "sample" after m
  38.   put m into the message box
  39. end changecard
  40.  
  41. on check fieldname
  42.   -- check one of two fields for illegal non-digits
  43.   put 1 into i
  44.   put char 1 of card field fieldname into x
  45.   repeat until x is empty
  46.     if x is in "0123456789" then
  47.       add 1 to i
  48.     else
  49.       put empty into char i of card field fieldname
  50.     end if
  51.     put char i of card field fieldname into x
  52.   end repeat
  53.   if card field fieldname is empty then
  54.     put 1 into card field fieldname
  55.   end if
  56. end check
  57.  
  58. on idle
  59.   -- make sure user does not enter a return or a non-digit
  60.   global oldticks
  61.   -- so idle doesn't go so often
  62.   if (the ticks - oldticks) > 240 then
  63.     put the ticks into oldticks
  64.     check("size")
  65.     check("line height")
  66.     closefield
  67.   end if
  68. end idle
  69.  
  70. on setSample
  71.   -- set up the sample field based on the text size selected
  72.   -- use the built in textheight to set the "line height" field
  73.   set the textsize of card field "sample" to card field "size"
  74.   put the textheight of card field "sample" into card field "line height"
  75.   changecard
  76. end setSample
  77.  
  78. on closefield
  79.   -- let the user type in any textsize they want
  80.   put the textsize of card field "sample" into x
  81.   if x <> card field "size" then
  82.     set the textsize of card field "sample" to card field "size"
  83.     put the textheight of card field "sample" into card field "line height"
  84.     changecard
  85.   else if the textheight of card field "sample" <> card field "line height" then
  86.     set the textheight of card field "sample" to card field "line height"
  87.     changecard
  88.   else  -- do nothing, no changes
  89.   end if
  90. end closefield
  91.  
  92. on hitsize
  93.   -- allow user to select a font size
  94.   put whichline(short name of target) into linenum
  95.   show card button "Hilite Size" at whereshow("font sizes",linenum)
  96.   put line linenum of card field "font sizes" into fontsize
  97.   put fontsize into card field "size"
  98.   setSample
  99. end hitsize
  100.  
  101. on hitfonts
  102.   -- allow user to select a font name
  103.   global fonts
  104.   hide card button "Hilite Size"
  105.   put whichline(short name of target) into linenum
  106.   show card button "Hilite Name" at whereshow("font names",linenum)
  107.   put line linenum of card field "font names" into fontname
  108.   set the textfont of card field "sample" to fontname
  109.   put empty into card field "font sizes"
  110.   set the scroll of card field "font sizes" to 0
  111.   repeat with i=2 to the number of items of line linenum of fonts
  112.     put item i of line linenum of fonts into line (i-1) of card field "font sizes"
  113.   end repeat
  114.   put line 1 of card field "font sizes" into card field "size"
  115.   show card button "Hilite Size" at whereshow("font sizes",1)
  116.   setSample
  117. end hitfonts
  118.  
  119. function whichline fieldname
  120. -- figure out which line of a field has been clicked
  121. return trunc(((scroll of card field fieldname) + (item 2 of the clickloc) - (item 2 of rect of card field fieldname)) div (the textheight of card field fieldname)) + 1
  122. end whichline
  123.  
  124. function whereshow fieldname,linenum
  125. -- figure out where line "linenum" of field "fieldname" is on screen
  126. put the rect of card field fieldname into x
  127. put trunc(((item 3 of x) - (item 1 of x) - 15) div 2) + (item 1 of x) into h
  128. put trunc((linenum * (the textheight of card field fieldname)) - (the scroll of card field fieldname) - (the textheight of card field fieldname)/2) + (item 2 of x) + 1 into v
  129. return h & "," & v
  130. end whereshow
  131.  
  132. on hitbox
  133.   -- hit one of the style check boxes
  134.   set the hilite of the target to not the hilite of the target
  135.   put the short name of the target into addstyle
  136.   put the textstyle of card field "sample" into oldstyle
  137.   if the hilite of the target is true then
  138.     if oldstyle is "plain" then
  139.       put addstyle into newstyle
  140.     else
  141.       put addstyle & "," & oldstyle into newstyle
  142.     end if
  143.   else
  144.     put offset(addstyle,oldstyle) into x
  145.     put empty into char x to x+(length of addstyle) of oldstyle
  146.     put oldstyle into newstyle
  147.   end if
  148.   put "set the textstyle of card field " & quote & "sample" & quote & "to " & newstyle into setstyle
  149.   do setstyle
  150.   changecard
  151. end hitbox
  152.  
  153. on hitbutton
  154.   -- handle the alignment radio buttons
  155.   global onbtn
  156.   set the hilite of card button onbtn to false
  157.   put the short name of the target into onbtn
  158.   set the hilite of card button onbtn to true
  159.   set the textalign of card field "sample" to onbtn
  160.   changecard
  161. end hitbutton
  162.  
  163. on opencard
  164.   -- initialize the card
  165.   global onbtn,fonts
  166.   hide the message box
  167.   set the lockscreen to true
  168.   hide card button "Hilite Size"
  169.   hide card button "Hilite Name"
  170.   put empty into card field "Font sizes"
  171.   put "left" into onbtn
  172.   set the hilite of card button "left" to true
  173.   set the hilite of card button "right" to false
  174.   set the hilite of card button "center" to false
  175.   repeat with i= 6 to 12  -- turn off style check boxes
  176.     set the hilite of card button i to false
  177.   end repeat
  178.   if card field "font names" is empty then
  179.     set the cursor to 4
  180.     put fontList() into fonts
  181.     repeat with i=1 to the number of lines in fonts
  182.       put item 1 of line i of fonts into line i of card field "font names"
  183.     end repeat
  184.   end if
  185.   set the scroll of card field "font names" to 0
  186.   set the scroll of card field "Font sizes" to 0
  187.   set the textfont of card field "sample" to "geneva"
  188.   set the textstyle of card field "sample" to "plain"
  189.   set the textalign of card field "sample" to "left"
  190.   set the textsize of card field "sample" to 12
  191.   put 12 into card field "size"
  192.   put the textheight of card field "sample" into card field "line height"
  193.   set the lockscreen to false
  194.   global oldticks
  195.   put the ticks into oldticks
  196. end opencard
  197.  
  198. on closecard
  199.   hide the message box
  200. end closecard
  201.  
  202.  
  203. -- part 1 (button)
  204. -- low flags: 00
  205. -- high flags: 2000
  206. -- rect: left=376 top=66 right=95 bottom=431
  207. -- title width / last selected line: 0
  208. -- icon id / first selected line: 0 / 0
  209. -- text alignment: 1
  210. -- font id: 0
  211. -- text size: 12
  212. -- style flags: 0
  213. -- line height: 16
  214. -- part name: OK
  215. ----- HyperTalk script -----
  216. on mouseUp
  217.   go to card 1
  218. end mouseUp
  219.  
  220.  
  221.  
  222. -- part 2 (button)
  223. -- low flags: 00
  224. -- high flags: 2000
  225. -- rect: left=376 top=100 right=120 bottom=430
  226. -- title width / last selected line: 0
  227. -- icon id / first selected line: 0 / 0
  228. -- text alignment: 1
  229. -- font id: 0
  230. -- text size: 12
  231. -- style flags: 0
  232. -- line height: 16
  233. -- part name: OK
  234. ----- HyperTalk script -----
  235. on mouseUp
  236.   go to card 1
  237. end mouseUp
  238.  
  239.  
  240.  
  241. -- part 3 (button)
  242. -- low flags: 00
  243. -- high flags: 6006
  244. -- rect: left=75 top=210 right=226 bottom=142
  245. -- title width / last selected line: 0
  246. -- icon id / first selected line: 0 / 0
  247. -- text alignment: 1
  248. -- font id: 0
  249. -- text size: 12
  250. -- style flags: 0
  251. -- line height: 16
  252. -- part name: Left
  253. ----- HyperTalk script -----
  254. on mouseUp
  255.   hitbutton
  256. end mouseUp
  257.  
  258.  
  259.  
  260. -- part 4 (button)
  261. -- low flags: 00
  262. -- high flags: 2006
  263. -- rect: left=75 top=225 right=241 bottom=142
  264. -- title width / last selected line: 0
  265. -- icon id / first selected line: 0 / 0
  266. -- text alignment: 1
  267. -- font id: 0
  268. -- text size: 12
  269. -- style flags: 0
  270. -- line height: 16
  271. -- part name: Center
  272. ----- HyperTalk script -----
  273. on mouseUp
  274.   hitbutton
  275. end mouseUp
  276.  
  277.  
  278.  
  279. -- part 5 (button)
  280. -- low flags: 00
  281. -- high flags: 2006
  282. -- rect: left=75 top=240 right=256 bottom=142
  283. -- title width / last selected line: 0
  284. -- icon id / first selected line: 0 / 0
  285. -- text alignment: 1
  286. -- font id: 0
  287. -- text size: 12
  288. -- style flags: 0
  289. -- line height: 16
  290. -- part name: Right
  291. ----- HyperTalk script -----
  292. on mouseUp
  293.   hitbutton
  294. end mouseUp
  295.  
  296.  
  297.  
  298. -- part 6 (button)
  299. -- low flags: 00
  300. -- high flags: 0005
  301. -- rect: left=75 top=81 right=97 bottom=158
  302. -- title width / last selected line: 0
  303. -- icon id / first selected line: 0 / 0
  304. -- text alignment: 1
  305. -- font id: 0
  306. -- text size: 12
  307. -- style flags: 0
  308. -- line height: 16
  309. -- part name: Bold
  310. ----- HyperTalk script -----
  311. on mouseUp
  312.   hitbox
  313. end mouseUp
  314.  
  315.  
  316.  
  317. -- part 7 (button)
  318. -- low flags: 00
  319. -- high flags: 0005
  320. -- rect: left=75 top=96 right=112 bottom=158
  321. -- title width / last selected line: 0
  322. -- icon id / first selected line: 0 / 0
  323. -- text alignment: 1
  324. -- font id: 0
  325. -- text size: 12
  326. -- style flags: 0
  327. -- line height: 16
  328. -- part name: Italic
  329. ----- HyperTalk script -----
  330. on mouseUp
  331.   hitbox
  332. end mouseUp
  333.  
  334.  
  335.  
  336. -- part 8 (button)
  337. -- low flags: 00
  338. -- high flags: 0005
  339. -- rect: left=75 top=111 right=127 bottom=158
  340. -- title width / last selected line: 0
  341. -- icon id / first selected line: 0 / 0
  342. -- text alignment: 1
  343. -- font id: 0
  344. -- text size: 12
  345. -- style flags: 0
  346. -- line height: 16
  347. -- part name: Underline
  348. ----- HyperTalk script -----
  349. on mouseUp
  350.   hitbox
  351. end mouseUp
  352.  
  353.  
  354.  
  355. -- part 9 (button)
  356. -- low flags: 00
  357. -- high flags: 0005
  358. -- rect: left=75 top=126 right=142 bottom=158
  359. -- title width / last selected line: 0
  360. -- icon id / first selected line: 0 / 0
  361. -- text alignment: 1
  362. -- font id: 0
  363. -- text size: 12
  364. -- style flags: 0
  365. -- line height: 16
  366. -- part name: Outline
  367. ----- HyperTalk script -----
  368. on mouseUp
  369.   hitbox
  370. end mouseUp
  371.  
  372.  
  373.  
  374. -- part 10 (button)
  375. -- low flags: 00
  376. -- high flags: 0005
  377. -- rect: left=75 top=141 right=157 bottom=158
  378. -- title width / last selected line: 0
  379. -- icon id / first selected line: 0 / 0
  380. -- text alignment: 1
  381. -- font id: 0
  382. -- text size: 12
  383. -- style flags: 0
  384. -- line height: 16
  385. -- part name: Shadow
  386. ----- HyperTalk script -----
  387. on mouseUp
  388.   hitbox
  389. end mouseUp
  390.  
  391.  
  392.  
  393. -- part 11 (button)
  394. -- low flags: 00
  395. -- high flags: 0005
  396. -- rect: left=75 top=156 right=172 bottom=158
  397. -- title width / last selected line: 0
  398. -- icon id / first selected line: 0 / 0
  399. -- text alignment: 1
  400. -- font id: 0
  401. -- text size: 12
  402. -- style flags: 0
  403. -- line height: 16
  404. -- part name: Condense
  405. ----- HyperTalk script -----
  406. on mouseUp
  407.   hitbox
  408. end mouseUp
  409.  
  410.  
  411.  
  412. -- part 12 (button)
  413. -- low flags: 00
  414. -- high flags: 0005
  415. -- rect: left=75 top=171 right=187 bottom=158
  416. -- title width / last selected line: 0
  417. -- icon id / first selected line: 0 / 0
  418. -- text alignment: 1
  419. -- font id: 0
  420. -- text size: 12
  421. -- style flags: 0
  422. -- line height: 16
  423. -- part name: Extend
  424. ----- HyperTalk script -----
  425. on mouseUp
  426.   hitbox
  427. end mouseUp
  428.  
  429.  
  430.  
  431. -- part 13 (field)
  432. -- low flags: 01
  433. -- high flags: 0007
  434. -- rect: left=169 top=66 right=260 bottom=307
  435. -- title width / last selected line: 0
  436. -- icon id / first selected line: 0 / 0
  437. -- text alignment: 0
  438. -- font id: 0
  439. -- text size: 12
  440. -- style flags: 0
  441. -- line height: 16
  442. -- part name: Font names
  443. ----- HyperTalk script -----
  444. on mouseup
  445.   -- allow user to select a font name
  446.   hitfonts
  447. end mouseup
  448.  
  449.  
  450. -- part 14 (field)
  451. -- low flags: 01
  452. -- high flags: 0007
  453. -- rect: left=319 top=66 right=195 bottom=367
  454. -- title width / last selected line: 0
  455. -- icon id / first selected line: 0 / 0
  456. -- text alignment: 0
  457. -- font id: 0
  458. -- text size: 12
  459. -- style flags: 0
  460. -- line height: 16
  461. -- part name: Font sizes
  462. ----- HyperTalk script -----
  463. on mouseup
  464.   hitsize
  465. end mouseup
  466.  
  467.  
  468. -- part 15 (field)
  469. -- low flags: 00
  470. -- high flags: 0002
  471. -- rect: left=319 top=201 right=223 bottom=368
  472. -- title width / last selected line: 0
  473. -- icon id / first selected line: 0 / 0
  474. -- text alignment: 0
  475. -- font id: 0
  476. -- text size: 12
  477. -- style flags: 0
  478. -- line height: 16
  479. -- part name: Size
  480.  
  481.  
  482. -- part 16 (field)
  483. -- low flags: 00
  484. -- high flags: 0002
  485. -- rect: left=376 top=201 right=223 bottom=430
  486. -- title width / last selected line: 0
  487. -- icon id / first selected line: 0 / 0
  488. -- text alignment: 0
  489. -- font id: 0
  490. -- text size: 12
  491. -- style flags: 0
  492. -- line height: 16
  493. -- part name: Line height
  494.  
  495.  
  496. -- part 17 (field)
  497. -- low flags: 01
  498. -- high flags: 2002
  499. -- rect: left=318 top=228 right=260 bottom=430
  500. -- title width / last selected line: 0
  501. -- icon id / first selected line: 0 / 0
  502. -- text alignment: 0
  503. -- font id: 3
  504. -- text size: 12
  505. -- style flags: 0
  506. -- line height: 16
  507. -- part name: Sample
  508.  
  509.  
  510. -- part 19 (button)
  511. -- low flags: 80
  512. -- high flags: 4000
  513. -- rect: left=170 top=227 right=243 bottom=290
  514. -- title width / last selected line: 0
  515. -- icon id / first selected line: 0 / 0
  516. -- text alignment: 1
  517. -- font id: 0
  518. -- text size: 12
  519. -- style flags: 0
  520. -- line height: 16
  521. -- part name: Hilite Name
  522.  
  523.  
  524. -- part 21 (button)
  525. -- low flags: 80
  526. -- high flags: 4000
  527. -- rect: left=320 top=67 right=83 bottom=350
  528. -- title width / last selected line: 0
  529. -- icon id / first selected line: 0 / 0
  530. -- text alignment: 1
  531. -- font id: 0
  532. -- text size: 12
  533. -- style flags: 0
  534. -- line height: 16
  535. -- part name: Hilite Size
  536. ----- HyperTalk script -----
  537. on mouseUp
  538.   send mouseup to card field "font sizes"
  539. end mouseUp
  540.  
  541.  
  542.  
  543. -- part 22 (button)
  544. -- low flags: 00
  545. -- high flags: A003
  546. -- rect: left=206 top=25 right=47 bottom=306
  547. -- title width / last selected line: 0
  548. -- icon id / first selected line: 0 / 0
  549. -- text alignment: 1
  550. -- font id: 0
  551. -- text size: 12
  552. -- style flags: 0
  553. -- line height: 16
  554. -- part name: See script
  555. ----- HyperTalk script -----
  556. on mouseUp
  557.   edit script of card
  558. end mouseUp
  559.  
  560.  
  561.  
  562. -- part contents for card part 17
  563. ----- text -----
  564. Sample
  565.  
  566. -- part contents for card part 16
  567. ----- text -----
  568. 16
  569.  
  570. -- part contents for card part 15
  571. ----- text -----
  572. 12